<!DOCTYPE html>
<html class="ui-page-login">

<head>
    <meta charset="utf-8">
    <title></title>
    <link th:href="@{/css/index.css}" rel="stylesheet"/>
    <script th:src="@{/js/jquery.js}"></script>
    <style type="text/css">
        html,
        body {
            padding: 0px;
            margin: 0px;
        }
    </style>
</head>

<body>
<div class="box">
    <div class="qdye">
        <img class="qdye_1" src="/image/left.png"/> 签到页
        <img class="qdye_2" src="/image/right.png"/>
    </div>
    <div class="hying">
        <span>欢迎莅临</span>
        <span>智汇未来</span>
        <span>2019HCR新品发布会</span>
        <span class="hy_width"></span>
    </div>
    <div class="photo">
        <img id="cav"/>
    </div>
    <div class="import">
        <input type="hidden" id="id" th:value="${id}" />
        <span class="text1">姓名</span><input type="text" id="name" value=""/>
        <span class="text2">公司名称</span><input type="text" id="company" value=""/>
    </div>
    <p class="hint">*（以上信息用于抽奖环节显示）</p>
    <button id="login" class="btn">提交</button>
</div>

<script type="text/javascript">
    setTimeout(function(){
        document.body.scrollTop = document.body.scrollHeight;
    },300);
    $(document).ready(function () {
        var id = $(" #id ").val();
        $.ajax({
            type: "GET",
            url: "/getImg?id=" + id,
            dataType: "text",
            success: function (data) {
                $("#cav").attr("src", data);
            },
            error: function (jqXHR) {
                console.log("Error: " + jqXHR.status);
            }
        });
    });
    $("#login").click(function () {
        var id = $(" #id ").val();
        var name = $(" #name ").val();
        var company = $(" #company ").val();
        if (name != "" && company != "") {
            $.ajax({
                type: "GET",
                url: "/save?id=" + id + "&name=" + name + "&company=" + company,
                dataType: "text",
                success: function (data) {
                    if (data == "1") {
                        location.href = "/ok"
                    }else {
                        location.href = "/err"
                    }
                },
                error: function () {
                    location.href = "/err"
                }
            });
        }
    });
</script>
</body>

</html>